package com.lry.protocol;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class RpcInvocation implements Serializable,Invocation {

    private static final long serialVersionUID = -3611379458492006176L;
    private String targetMethod;

    private String targetServiceName;

    private Object[] args;

    private Class[] argTypes;

    private Map<String,Object> attachments = new HashMap<>();

    public Object getHead(String key){
        return attachments.get(key);
    }

    public void addHeads(Map<String,Object> heads){
        attachments.putAll(heads);
    }

    public void addHead(String key,Object value){
        attachments.put(key,value);
    }
}
